import { RouteRecordRaw } from "vue-router";

export function mapMenusToRoutes(userMenus: any[]): RouteRecordRaw[] {
  const routes: RouteRecordRaw[] = [];
  // 1先去加载所有的路由
  const allRoute: RouteRecordRaw[] = [];
  const routeFiles = require.context("../router/main", true, /\.ts/);
  console.log(routeFiles);

  routeFiles.keys().forEach((key) => {
    console.log(key);

    const route = require("../router/main" + key.split(".")[1]);
    allRoute.push(route.default);
    console.log(route);
  });
  console.log(allRoute);
  // 2根据菜单获取所有的routers

  return routes;
}
